package com.sairobo.base.common.utils;

import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.Collection;

/**
 * 断言
 * @author shengming
 * @version V1.0
 * @description:
 * @date 2017/11/5 16:15
 */

public class Assert extends org.springframework.util.Assert{

    public static void notNull(Object object,String message) {
        if (object == null) {
            throw new IllegalArgumentException(message);
        }
        if (object instanceof String) {
            if (StringUtils.isEmpty(object.toString())) {
                throw new IllegalArgumentException(message);
            }
        }
        if(object instanceof Collection){
            if(CollectionUtils.isEmpty((Collection)object)){
                throw new IllegalArgumentException(message);
            }
        }
    }


    public static void hasText(String... text) {
        for (String t : text) {
            Assert.hasText(t);
        }
    }


}
